AddCSLuaFile( "cl_init.lua" );
AddCSLuaFile( "shared.lua" ); 
AddCSLuaFile( "VGUI.lua" );
AddCSLuaFile( "HUD.lua" );
 
include( "shared.lua" );
include( "SQL.lua" );
include( "ServertoClient.lua" );
require( "datastream" );

A = false;

function GM:PlayerInitialSpawn( ply ) 
	A = !A;
	if A then
		ply:SetTeam( 21 );
	else
		ply:SetTeam( 20 );
	end
	
	timer.Simple( 5, function()
		SendUserMessage( "Motd", ply, ply:Nick() );
	end );
	
end 
 
function GM:PlayerLoadout( ply ) 
 
    if ply:Team() == 21 then 
 
        ply:Give( "weapon_physcannon" ); -- still need to make the SWEPS 
		ply:Give( "weapon_physgun" );
		ply:Give( "weapon_knife" );
    end 
	
	if ply:Team() == 20 then 
 
        ply:Give( "weapon_physcannon" ); -- still need to make the SWEPS 
		ply:Give( "weapon_physgun" );
		ply:Give( "weapon_knife" );
    end
 
end

function GM:ShowSpare1( ply )
	SendUserMessage( "Motd", ply, ply:Nick() );
end

function PlayerNoclip( ply )
	
	if ply:IsAdmin() then 
		return true; 
	else 
		return false;
	end

end
hook.Add( "PlayerNoclip", PlayerNoclip, PlayerNoclip )



function AcceptStream( ply, handler, id )
	if ( handler == "savestats" or handler == "saveinv" ) then return true; end
end
hook.Add("AcceptStream", "Saveing.AcceptStream", AcceptStream);
	
function Saveplayer( pl, handler, id, encoded, decoded )
	savePlayer( pl, decoded[ 1 ], decoded[ 2 ], decoded[ 3 ], decoded[ 4 ], decoded[ 5 ] )
end
datastream.Hook( "Saveplayer", Saveplayer )
	


-- function Set_Team_1( ply )

	-- if ply:Team() != 20 then 
		-- ply:ChatPrint("Swiched to team 1");
		-- ply:SetTeam( 20 );
	-- else
		-- ply:ChatPrint( "You are already a member!" );
	-- end
	
-- end

-- function Set_Team_2( ply )

	-- if ply:Team() != 21 then 
		-- ply:ChatPrint("Swiched to team 2");
		-- ply:SetTeam( 21 );
	-- else
		-- ply:ChatPrint( "You are already a member!" );
	-- end
	
-- end

concommand.Add( "Set_Team_1", Set_Team_1 );
concommand.Add( "Set_Team_2", Set_Team_2 );